// import { toast } from "@/utils/common";
export function downLoadImg(url, is_video) {
  uni.showLoading({
    title: "加载中",
  });
  uni.downloadFile({
  	url : url,
  	success: (res) => {
  		uni.hideLoading();
  		if (res.statusCode === 200) {
  			if(is_video==false){
  				// 图片下载
  				uni.saveImageToPhotosAlbum({
  					filePath: res.tempFilePath,
  					success: function() {
  						uni.showToast({
  							title: "已保存到相册",
  							icon: "none"
  						});
  					},
  					fail: function() {
  						uni.showToast({
  							title: "保存失败，请稍后重试",
  							icon: "none"
  						});
  					}
  				});
  			}else{
  				// 视频下载
  				uni.saveVideoToPhotosAlbum({
  					filePath: res.tempFilePath,
  					success: function() {
  						uni.showToast({
  							title: "已保存到相册",
  							icon: "none"
  						});
  					},
  					fail: function() {
  						uni.showToast({
  							title: "保存失败，请稍后重试",
  							icon: "none"
  						});
  					}
  				})
  			}
  		}else {
  			uni.showToast({title:"资源格式错误，请联系管理员",icon: "none"});
  		}
  	},
  	fail: (err) => {
  		uni.showToast({title: "保存失败，请联系管理员",icon: "none"});
  	}
  })
}
export function checkFile(url){
	uni.downloadFile({
		url,
		success: function (res) {
		  var filePath = res.tempFilePath;
		  uni.openDocument({
			filePath: filePath,
			showMenu: true,
			success: function (res) {
			  console.log('打开文档成功');
			}
		  });
		}
	  });
}